package com.itfenghuang.test;

public class A00_生产者 extends Thread {
    @Override
    public void run() {
        while (true){
            synchronized (A00_共享资源.obj){
                if (A00_共享资源.num==0){
                    break;
                }else {
                    if (!A00_共享资源.flag){
                        System.out.println("厨子做面包");
                        A00_共享资源.flag=true;
                        A00_共享资源.num--;
                        A00_共享资源.obj.notifyAll();
                    }else {
                        try {
                            A00_共享资源.obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
